package com.situ.mall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.situ.mall.mapper.OrderItemMapper;
import com.situ.mall.pojo.query.OrderQuery;
import com.situ.mall.pojo.vo.OrderItemVO;
import com.situ.mall.service.IOrderService;
import com.situ.mall.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class OrderServiceImpl implements IOrderService {

    @Autowired
    private OrderItemMapper orderItemMapper;

    @Override
    public PageResult<OrderItemVO> list(OrderQuery orderQuery) {
        PageHelper.startPage(orderQuery.getPage(), orderQuery.getLimit());
        List<OrderItemVO> list = orderItemMapper.list(orderQuery);
        PageInfo<OrderItemVO> pageInfo = new PageInfo<>(list);
        int count = (int) pageInfo.getTotal();
        return new PageResult<>(0, "", count, list);
    }
}
